package com.qidianit.mes.pro.controller;

import com.github.pagehelper.PageInfo;
import com.qidianit.mes.pojo.Process;
import com.qidianit.mes.pojo.Result;
import com.qidianit.mes.pro.service.ProcessService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @ Description:
 * @ Author:WuJingLei
 * @ Date: 2025/9/17 -15:37
 */
@RestController
@RequestMapping("/process")
public class ProcessController {
    @Autowired
    private ProcessService processService;

    @GetMapping("/page")
    public Result<PageInfo<Process>> page(Process process,
                                          @RequestParam(defaultValue = "1") int page,
                                          @RequestParam(defaultValue = "10") int size){
        return processService.queryProcesses(process,page,size);
    }

    @PostMapping("/add")
    public Result<Process> add(@RequestBody Process process){
        return processService.addProcess(process);
    }

    @GetMapping("/code/{code}")
    public Result<Process> code(@PathVariable String code){
        return processService.queryProcess(code);
    }

    @PutMapping("/update")
    public Result update(@RequestBody Process process){
        return processService.updateProcess(process);
    }

    @DeleteMapping("/delete/{id}")
    public Result delete(@PathVariable Long id){
        return processService.deleteProcess(id);
    }

    @DeleteMapping("/batchDelete")
    public Result batchDelete(Long[] id){
        return processService.batchDelete(id);
    }

}
